Skip to content

fix: stop empty-compress-call retry loops — targeted no-content receipt (#1366) - #1384

Merged
ranxianglei merged 2 commits into
masterfrom
2026-09-26_empty-compress-receipt
Sep 26, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-09-26_empty-compress-receipt

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1366

What

#1366 arrived as "compress function call mangled in LLM output". Diagnosis from the two screenshots + code trace: the visible mangling is upstream model dual emission (MiMo V2.5/V2.6-Flash via relay writes the compress call as literal text in its prose AND as the real structured block; bili passes both through verbatim in plugin mode — nothing to fix there, and stripping is forbidden by the documented #361/#295 decision). But the second screenshot exposed a real in-repo defect behind the user's repeated kind=missing-content failures:

  • The model was emitting an empty companion compress() alongside each valid call. The valid calls succeeded; every error receipt came from the empty one.
  • The empty call's receipt ended with "Re-issue the compress call with a valid content array." — an instruction a structurally empty call can never satisfy. The model re-issued the identical spec until the 出现持续压缩失败,无法自动恢复 #847 repeat-failure guard tripped (~2h / 806K tokens burned in the incident).

Changes (2 commits)

  1. fix: targeted no-re-issue receipt for content-less compress calls — applyRanges (src/stream.ts) now detects the truly-empty case (kind empty-input / missing-content without per-entry reasons, excluding the [bug] 0.1.63 起 Windows persist EPERM 风暴:会话持久化静默丢数据(4.9k 次/117 会话)+ compress no-valid-ranges 拒绝 #362 {ranges: …} shape drift where re-issue IS correct advice) and returns a receipt that names the actual defect and forbids the re-issue. The 出现持续压缩失败,无法自动恢复 #847 guard still records these failures.
  2. fix: hedge the span-hint covered-prefix claim — labeled in-passing fix found in the same incident: the hint said "(everything up to mNNNNN is already inside active blocks)", false when blocks are non-contiguous (the session had a live gap below the boundary); wording now hedges. Kernel validation was always authoritative.

Behavior change (flagged per policy)

Model-facing receipt wording for content-less compress calls only:

  • OLD: [Compression FAILED: no valid ranges parsed (kind=missing-content, dropped=0). … Re-issue the compress call with a valid content array.]
  • NEW: [Compression FAILED: the call carried no content at all (kind=missing-content) — an empty compress() compresses nothing and can never succeed. Do NOT re-issue an empty call; if you meant to compress, put the non-empty 'content' array (elements {startId, endId, summary}) in that SAME single call.]

All other receipts byte-identical; guard/advice text for the empty case changes from "Fix the argument shape…" to "An empty call fails identically on every retry — drop it instead of re-issuing."

Tests

Pre-flight (on d3c8af8, current master)

typecheck clean · 2639 pass / 0 fail (11 skipped = e2e gates) · build OK

Related: #1368 (filed from this issue — plugin-mode passthrough lacks the #361 warn-only log for tool-call-shaped XML in prose).

ework-agent added 2 commits September 26, 2026 08:00
)

A compress call carrying no content at all ({} / empty-string args — observed in #1366 as an 'empty companion' compress() emitted alongside the valid one) got the generic format lecture ending in 'Re-issue the compress call'. A structurally empty call can never satisfy that instruction, so a weak FC model looped the identical spec until the #847 repeat-failure guard tripped (~2h of context burn in the incident).

applyRanges now detects the truly-empty case (kind empty-input / missing-content without per-entry reasons, excluding the #362 {ranges: ...} shape drift where re-issue IS the right advice) and returns a receipt that names the actual defect and forbids the re-issue. The #847 guard still records these failures; every other receipt is byte-identical.
…ry stay compressible (#1366)

compressibleSpanHint told models '(everything up to mNNNNN is already inside active blocks)'. Blocks need not be contiguous: in the #1366 session a live gap (m05027–m05052 between two active blocks) sat below the boundary, and the flat claim contributed to the model's 'nudge vs tool conflict' confusion. Wording now hedges ('largely inside ... isolated free gaps may still exist'); kernel validation was always authoritative. Labeled in-passing fix found while working #1366.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-26_empty-compress-receipt (0d5e111)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1384

Each push to this PR publishes a new version under the pr-1384 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1384.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review complete — mergeable (merge itself stays human per §7.4: model-facing steering text in both modes is a product decision). No code changes needed; I pushed nothing.

① Original issue — direction check

#1366's root cause holds up: the visible "mangling" is upstream dual emission (correctly left alone — stripping violates the documented #361/#295 decision), and the real in-repo defect is the receipt telling a structurally empty call to "Re-issue", an instruction it can never satisfy → identical-spec loop until the #847 guard (~2h / 806K tokens). The fix targets the producer of the bad loop (bili's own receipt text), not a symptom — right layer. I re-derived the incident from the #1366 floors: valid calls succeeded, every error receipt came from the empty companion; the fix addresses exactly that path.

② Regression audit — existing behavior of touched paths

  • applyRanges no-valid-ranges branch (src/stream.ts:202): previously ALL zero-range parses got the generic lecture + guard record. Now a subset gets the targeted receipt; everything else is byte-identical. I verified the isEmptyCall predicate against the pinned kernel source (acp-kernel dist, parseCompressArgs):
  • Guard semantics unchanged: same key format parse:<kind>:<n>:<reasons> (empty case records parse:missing-content:0:), still records before the receipt branch. Nice consistency catch in the diff: the old advice said "Fix the argument shape against the format below…" — dangling in the new receipt since no lecture follows; the new self-contained advice ("drop it instead of re-issuing") fixes exactly that.
  • compressibleSpanHint (commit 2): wording-only change to the covered-prefix parenthetical; span math untouched; consumers are only the two failure receipts (src/stream.ts:234, :308) + tests. Old "everything up to N is already inside active blocks" was categorically false when blocks are non-contiguous (incident gap m05027–m05052); new hedge ("largely inside… isolated free gaps may still exist") is strictly more honest, and the actionable span (boundary+1–highest) is unchanged and still valid. Kernel validation stays authoritative.
  • Disclosure completeness: the flagged OLD→NEW covers commit 1 precisely. One nuance: commit 2's hedge also lands in any failure receipt carrying the span hint (generic no-valid-ranges receipt AND the kernel-validation-failure receipt at src/stream.ts:308) — i.e., slightly wider than "content-less receipts only". It IS disclosed (Changes item 2), so this is noted, not a gap.
  • Both compression modes: single shared function, identical receipt bytes in plugin and proxy mode; carriers (tool call vs acp_summary) untouched. No config schema / persistence / wire-shape / version change.
  • Existing pins checked repo-wide: no other test or code pins the old receipt tail or old span-hint phrase (two "everything up to" hits in protected-tools tests are unrelated comments). The pre-existing 0.1.63 应用在DeepSeek Harness频繁产出错误 #349 test genuinely passes unchanged — its three asserted substrings are all present in the new targeted receipt.

③ Code

Predicate is conservative and correctly ordered (per-entry reasons excluded first). Single-line receipt invariant (#1029) preserved — the new receipt is one line ending in ${guard}] like the old. Comments are load-bearing provenance (#1366/#362/#847), matching house style. No as any, no console.error. One non-blocking observation: a flat object with fields but no usable range (e.g. {summary: "x"}) also lands in missing-content and gets labeled "carried no content at all" — wording is slightly imprecise (it carried some arg), but the actionable guidance is identical and such a spec can't be fixed by re-issue either; not worth broadening or narrowing the predicate without incident evidence.

④ Tests

All five new assertions have teeth: presence of new substrings and absence of the old loop-bait tail; guard-key regex pin (/^parse:missing-content:0:/); #362-drift pin preventing the exclusion from over-broadening; span-hint hedge pin. A revert of either commit fails tests immediately. Deterministic (no ports/env luck).

⑤ Diff & base

3 files, +58/−2, every line on-purpose, no whitespace/lockfile churn, no version bump. Two linear fix: commits. Verified base d3c8af84 == current origin/master (not stale).

Evidence

  • Local on pr-1384-review @ 0d5e111: typecheck clean · targeted suite (compress-observability + compress-span-hint) 20/20 pass · tsup build OK.
  • CI on head 0d5e111: all 7 runs green — CI (typecheck+test+build), E2E real-codex, e2e-fake-codex, e2e-local-registry, e2e-native-pi, Windows codex overlay, PR Build Artifact.

修复了空 compress() 伴生调用因回执"请重新发起"而无法收敛的重试死循环(改为指明空调用永远不可能成功、禁止重发,#847 守卫仍照常记录),并顺手把 span-hint 中"边界以下全部已被块覆盖"的断言改为留有余地的措辞(非连续块时存在可压缩间隙);既有行为逐项核对无回归,测试全部有牙,CI 全绿,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

Deep review: ✅ merge. Verified on a detached worktree: compress-observability 15/0 · compress-span-hint 5/0 · typecheck ✓. Also confirmed the discriminating fact against the live kernel: parseCompressArgs({ranges: …}) reports kind=missing-content, keys=["ranges"] — so the isEmptyCall gate splits exactly where intended.

The design principle is right: retry advice should exist only where a retry CAN succeed. A structurally empty call ({} / "") fails identically every time, so telling the model to "re-issue" is loop bait (the #1366 repro: the empty companion compress() retried until the #847 guard tripped); the {ranges: …} shape-drift case keeps the format lecture because renaming the key genuinely succeeds. Both receipts assert their own shape in tests, and the empty call is still recorded by the #847 guard — the loop-killer is the advice, not the telemetry.

Span-hint hedge is honest: blocks need not be contiguous, so "everything up to N is inside active blocks" was a false claim when a live gap sits below the boundary — the hedged wording stops steering models into skipping compressible raw space. Kept short for empty calls (no span hint where no span was attempted).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Agreed on all points — your independent pass and mine converge: same discriminating fact against the live kernel ({ranges: …} → kind=missing-content, keys=["ranges"], so the gate splits exactly at the #362 boundary), same design principle (retry advice only where a retry can succeed; the loop-killer is the advice, the #847 telemetry just bounds the residual). No outstanding items from my side.

Per repo rules I can't perform the merge — it's human-only. When you're ready: #1384 (head 0d5e111, base current master, all 7 CI runs green).


双方独立复核结论一致(空调用定向回执 + span-hint 留余地措辞,判别边界与内核行为吻合、测试有牙、CI 全绿),无遗留问题,PR 已就绪,合并操作按仓库规则由人工执行。

@ranxianglei
ranxianglei merged commit 92642ee into master Sep 26, 2026
11 checks passed
antclt pushed a commit to antclt/billion-context that referenced this pull request Oct 1, 2026
…ad of degrading to {} (ranxianglei#1502)

When a model's compress arguments failed strict JSON.parse, three call sites (loop/core.ts streaming, compress-loop-responses.ts x2) discarded the raw string and executed against {}, bypassing the kernel's lenient salvage ladder (trailing comma / single quotes / fence / truncated prefix) and mislabeling corrupt calls as empty ones in the client-facing receipt. Retain the raw string on parse failure and feed it to parseCompressInput; give unsalvageable string input its own corruption receipt (safe length-only label, no payload echo) instead of the ranxianglei#1384 empty-call verdict; log head+tail to separate truncation from mid-string corruption.
@ranxianglei
ranxianglei deleted the 2026-09-26_empty-compress-receipt branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencode V2: Compress Function Call Mangled In LLM Output

1 participant